home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2007 December
/
PCWKCD1207B.iso
/
Windows marzen
/
Macro ToolsWorks 6.31
/
tworks.exe
/
Samples
/
Add prefix and postfix text to each line in text file.mcr
< prev
next >
Wrap
Text File
|
2003-08-14
|
1KB
|
42 lines
<#>
<#> This sample adds prefix and postfix text to each line in a selected text file
<#>
<cmds>
<form_item>("f1","Input file:","EDIT_FILE","*.txt","vInputFile")
<form_item>("f1","Output file:","EDIT_FILE","%_vFolder_Temp%\output.txt","vOutputFile")
<form_item>("f1","Prefix:","EDIT",">>>","vPrefix")
<form_item>("f1","Postfix:","EDIT","<<<","vPostfix")
<form_show>("f1","Form","shell32.dll",0,,0)
<if_str>("_vCanceled==1")<exitmacro><endif>
<data_load>("vbTemp_FileText","vInputFile","")
<data_save>("","vOutputFile","")
<if_str>("_vErr==NO")
<var_oper>(vbTemp_NumOfLines,"vbTemp_FileText",TEXT_GET_NUMOFLINES,"","", "0")
<begloop>(vbTemp_NumOfLines)
<varset>("v100=EXPR(%_vLoopCounter%/100)","")
<if_num>("_vLoopCounter == EXPR(100*%v100%)")
<msgoff>
<msg>(32,32,"%_vLoopCounter% lines of %vbTemp_NumOfLines% processed.","Processing",0)
<endif>
<var_oper>(vbTemp_LineText,"vbTemp_FileText",TEXT_GET_LINE,"_vLoopCounter","", "0")
<var_oper>(vbTemp_LineText,"%vbTemp_LineText%",STR_INSERT,"0","%vPrefix%", "0")
<var_oper>(vbTemp_LineText,"%vbTemp_LineText%",STR_APPEND,"%vPostfix%%_vKeyReturn%","", "0")
<data_save>("vbTemp_LineText","vOutputFile","A")
<endloop>
<else>
<msg>(-100,-100,"_vError","File Error",1)
<endif>
<msg>(-100,-100,"Do you want to open output file now?","Message",2)
<if_str>("_vMsgButton==YES")
<fileopen>("%vOutputFile%",0)
<endif>